#include "gd32f10x.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
#include "usart_com.h"
#include "i2c.h"
#include "lm75ad.h"
#include "oled.h"

/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/

int main(void)
{
    float temp = 0.0;
    char buf[100] = {0};
    systick_config();
    i2c0_init();
    oled_init();
		oled_clear_all();
    oled_show_string(0, 0, (uint8_t *)"mss", 16);

    while (1)
    {
        temp = lm75ad_get_temp();
        sprintf(buf, "temp is %.3f!\n", temp);
        oled_show_string(0, 2, (uint8_t *)buf, 16);
        delay_1ms(1000);
    }
}

/* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f)
{
    //    usart_data_transmit(EVAL_COM0, (uint8_t)ch);
    //    while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));

    return ch;
}
